#ifndef QPROJECTTREEWIDGET_H
#define QPROJECTTREEWIDGET_H

#include "./toObject/ModelXml.h"
#include <QStandardItem>
#include <QTreeWidget>
class QProjectTreeWidget : public QTreeWidget {
    Q_OBJECT
public:
    explicit QProjectTreeWidget(QWidget* parent = nullptr);
    enum Node_Type {
        Node_Project = 1,
        Node_CollectChannel,
        Node_CollectChannelArray,
        Node_CollectDev,
        Node_UpdateChannel,
        Node_UpdateChannelDEV
    };

    //采集
    void AddProject(stProject project, bool writexml = true);
    void AddCollectChannel(stCollectChannel channel, bool writexml = true);
    void AddCollectDevice(int channelID, stCollecDevice device, bool writexml = true);

    void DelCollectChannel(int channelID);
    void DelCollectDevice(int channelID, int deviceID);
    void DelUpdateChannel(int channelID);

    int GetCollectChannelMaxID();
    //    int GetCollectDeviceMaxID();
    //转发
    void AddUpdateChannel(stUpdateChannel updateChannel, bool writexml = true);

    bool InitOpenProject(QString filePath);

    bool DeleteProject();

private:
    ModelXml* m_modeData;

private:
    QTreeWidgetItem* m_projectItem { nullptr }; //工程节点
    QTreeWidgetItem* m_collectItem { nullptr }; //采集节点
    QTreeWidgetItem* m_updateItem { nullptr }; //上传节点

    QMap<int, QTreeWidgetItem*> m_collectChannelItem;
signals:
};

#endif // QPROJECTTREEWIDGET_H
